<?php
class lib_company_shop extends lib_base{
	public $table_name = "qc_company_shop";
    public $pk = "id";
    
    public function add_log($data){

        $arrBase = array(
            'company_id' =>$data['company_id'],
            'admin_id' =>$data['admin_id'],
            'type' =>$data['type'],
            'money' =>$data['money'],
			'msg' =>$data['msg'],
			'status' =>1,
			'add_time'=>date('Y-m-d H:i:s'),
		);
		return $this->add($arrBase);
    }

    public function up_status($log_id){

        $arrBase = array(
			'status' =>1,
			'up_time'=>date('Y-m-d H:i:s'),
		);
		return $this->edit($log_id,$arrBase);
    }

    public function get_detail($shop_id){
        
    	$info = $this->get_info($shop_id);
    	if($info){
           
            $info['area'] = D('company_area')->get_info($info['area_id']);
            $info['parea'] = D('company_area')->get_pinfo($info['area_id']);

			$info['cate'] = D('company_cate')->get_info($info['cate_id']);
            $info['pcate'] = D('company_cate')->get_pinfo($info['cate_id']);

			$info['zone'] = D('company_zone')->get_info($info['zone_id']);
            $info['pzone'] = D('company_zone')->get_pinfo($info['zone_id']);

	        if($info['photo']){
                $photos_arr = explode(',', $info['photo']);
                foreach($photos_arr as $v){
                    $info['photos'][$v] = D('upload_file')->get_image_url($v);
                }
			}
			return $info;
    	}
    	return false;

    }

    public function get_shop_data($company_id,$admin_id){
        $cond = "status=1 and company_id='{$company_id}' and admin_id='{$admin_id}'";
        $res = $this->findAll(array($cond));
        // return get_child_data($res);
        return $res;
    }
}